package com.kw.drug.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kw.drug.entity.Druginfo;
import com.kw.drug.entity.Problem;
import com.kw.drug.mapper.ProblemMapper;
import com.kw.drug.service.ProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProblemServiceImpl implements ProblemService {
    @Autowired
    ProblemMapper problemMapper;

    @Override
    public IPage<Problem> problemQueryPage(int pageNum, int pageSize, String param) {
        QueryWrapper<Problem> wrapper = new QueryWrapper<>();

        if (StringUtils.isNotEmpty(param)) {
            wrapper.like("dname", param);
        }
        Page<Problem> page = new Page<>(pageNum, pageSize);
        return problemMapper.selectPage(page, wrapper);
    }

    @Override
    public Problem queryProblemById(Integer id) {
        Problem problem = problemMapper.selectById(id);
        return problem;
    }

    @Override
    public Integer problemDelById(Integer id) {
        int i = problemMapper.deleteById(id);
        return i;
    }

    @Override
    public Integer addProblem(Problem problem) {
        int insert = problemMapper.insert(problem);
        return insert;
    }


}
